// createRouter路由实例
import { createRouter, createWebHashHistory } from 'vue-router'
// 导入路由组件
import Layout from '@/views/Layout'
import Login from '@/views/Login'
import Home from '@/views/Home'
import Category from '@/views/Category'
import Goods from '@/views/goods'
import Cart from '@/views/cart'
import Settle from '@/views/settle'
import Pay from '@/views/pay'
import Callback from '@/views/Callback'
const routes = [
  {
    path: '/',
    component: Layout,
    children: [
      // 首页路由
      {
        path: '',
        component: Home
      },
      // 分类路由
      {
        path: 'category/:id',
        component: Category
      },
      // 商品详情路由
      {
        path: 'goods/:id',
        component: Goods
      },
      // 购物车结算界面
      {
        path: 'cart',
        component: Cart
      },
      {
        // 列表结算
        path: 'settle',
        component: Settle
      },
      {
        // 支付
        name: 'pay',
        path: 'pay/:id',
        component: Pay
      },
      {
        // 结算完成

        path: 'pay/callback',
        component: Callback

      }
    ]
  },
  {
    path: '/login',
    component: Login
  }
]
// 创建路由实例，挂载histroy路由模式
const router = createRouter({
  history: createWebHashHistory(process.env.BASE_URL),
  routes
})
// 导出路由
export default router
